package com.ruslan.magaz.web;


import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;

import com.ruslan.magaz.Role1;

public class RoleDao {
	@PersistenceContext
	private EntityManager em;
	
	
	public void addRole(Role1 role){
		
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("main");
		EntityManager em = emf.createEntityManager(); // Retrieve an application managed entity manager
		// Work with the EM
		em.getTransaction().begin();
		em.persist(role);
		em.getTransaction().commit();
		em.close();
		emf.close(); //close at application end
	}
	
}
